import HwTestReport
import unittest
import time
import sys
sys.path.append('D:\\.jenkins\\workspace\\autoproject\\quote')
from quote.base.userbrowser import UseBrowser
from quote.util.operationxel import OperationExl
from quote.webpage.usermanager.loginpage import LoginPage


class LoginSuc(unittest.TestCase):

    def setUp(self) -> None:
        self.loginpage = LoginPage()
        self.oe=OperationExl()

    def test_1_login_suc(self):
        self.loginpage.login(self.oe.get_cell_value(1,2),self.oe.get_cell_value(1,3))
        actur_text=self.loginpage.get_suc_text()
        print(actur_text)
        self.assertEqual("欢迎使用报价管理系统",actur_text)
        time.sleep(2)

    # def test_2_login_suc(self):
    #     self.loginpage.login("admin", "admin")
    #     time.sleep(2)
    #
    # def test_3_login_suc(self):
    #     self.loginpage.login("admin", "admin")
    #     time.sleep(2)

    def tearDown(self) -> None:
        UseBrowser.quit()



if __name__ == '__main__':
    su = unittest.TestSuite()
    case_2 = unittest.TestLoader().loadTestsFromTestCase(LoginSuc)
    case = [case_2]
    su.addTests(case)
    now = time.strftime("%y_%m_%d_%H_%M", time.localtime())
    with open('../../../my_report{}.html'.format(now), 'wb+') as fp:
        runner = HwTestReport.HTMLTestReport(stream=fp,
                                             title='My auto test',
                                             description='This demonstrates the report output by HTMLTestRunner.',
                                             verbosity=3)
        runner.run(su)
